
import static java.lang.Math.*;
/**
 * Created with IntelliJ IDEA.
 * Description:访问类变量
 * User: 86183
 */
class Student{
    //成员变量
    public String name;
    public String gender;
    public int age;
    private static String className = "1班";

    public Student() {
    }

    public Student(String name, String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    public static String getClassName(){
        Student student = new Student();
        student.name = "小霖";
        student.gender = "男";
        student.age =20;
        student.print();
//        //静态成员方法并不能调用非静态成员变量和成员方法，因为非静态成员变量和成员方法依赖于对象，只能通过对象的引用来访问
//        this.name = "小霖";
//        print();
        return className;
    }
   /*public static void getClassName(){
       System.out.println(className);
   }*/
   public void print(){
       System.out.println("姓名: "+this.name+", " +"性别: "+this.gender+", "+"年龄; "+this.age);
       //getClassName();
   }
}
public class Test5 {
    public static void main(String[] args) {
        //Student.getClassName();
        /*//非静态成员方法直接调用静态成员方法
        Student student = new Student("小贺","男",20);
        student.print();*/
        //通过类名来访问
        System.out.println(Student.getClassName());
        System.out.println("==============");
        //通过对象的引用来访问
        Student student = new Student();
        System.out.println(student.getClassName());

    }

}
